package com.taotao.thread.Test1;

/**
 * @author wangjin
 * @title: Test3
 * @projectName thread
 * @description: 某个锁的对象
 * @date 2022/5/3 0003 14:57
 */
public class Test3  implements Runnable{
    private  int count=20;
    private  Object object = new Object();
    public static void main(String[] args) {
      new Thread(new Test3()).start();
    }
    public void m(){

    }

    @Override
    public void run() {
        //任何线程想要执行下面的代码，必须先拿到o锁
        synchronized (object){
            count--;
            System.out.println(Thread.currentThread().getName()+"count="+count);
        }
    }
}
